﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/Oceania.Master"
    AutoEventWireup="true" CodeBehind="BlogEntry.aspx.cs" Inherits="Blog.Net.Web.Blog.BlogEntry"
    ValidateRequest="false" %>

<asp:Content ContentPlaceHolderID="mainContent" runat="server">
    <asp:FormView ID="blogFormView" DataSourceID="blogs" DataKeyNames="Id" AllowPaging="true"
        runat="server">
        <PagerSettings Mode="NextPrevious" PreviousPageText="Previous" NextPageText="Next" />
        <ItemTemplate>
           <div class="box">
                <h2>
                    <%# DataBinder.Eval(Container.DataItem, "Subject") %></h2>
                <p class="byline">
                    <small>Posted on
                        <%# DataBinder.Eval(Container.DataItem, "LongCreateDate") %></small></p>
                <p>
                    <%# DataBinder.Eval(Container.DataItem, "Body") %>
                </p>
            </div>
            <!--<blg:Rating EntryId='<%# Eval("Id") %>' runat="server" />-->
            <br />
            <asp:LoginView ID="EditLoginView" runat="server">
                <LoggedInTemplate>
                    <asp:LinkButton ID="editButton" CommandName="Edit" Text="Edit" runat="server" />
                    &nbsp;|&nbsp;
                    <asp:LinkButton ID="deleteButton" CommandArgument='<%# Eval("Id") %>' Text="Delete"
                        OnClick="deleteButton_Click" runat="server" />
                    &nbsp;|&nbsp;
                    <asp:LinkButton ID="insertButton" CommandName="New" Text="Add" runat="server" />
                </LoggedInTemplate>
            </asp:LoginView>
        </ItemTemplate>
        <InsertItemTemplate>
            <asp:LoginView ID="loginView" runat="server">
                <LoggedInTemplate>
                    <h1>
                        New Blog Entry</h1>
                    <asp:Label ID="subjectLabel" Text='Subject' runat="server" />
                    <asp:TextBox ID="subject" Text='<%# Eval("Subject") %>' Width="300px" runat="server" /><br />
                    <asp:RequiredFieldValidator ID="subject_RequiredFieldValidator" ControlToValidate="subject"
                        Text="*" ErrorMessage="'Subject' is required." SetFocusOnError="True" runat="server" />
                    <br />
                    <ftb:FreeTextBox ID="body" Text='<%# Eval("Body") %>' ImageGalleryPath="~/Blog/Images"
                        ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,Strikethrough,Superscript,Subscript,RemoveFormat|Cut,Copy,Paste,Delete;Undo,Redo,Print,Save|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertImageFromGallery,NetSpell"
                        Width="100%" runat="server" />
                    <asp:RequiredFieldValidator ID="body_RequiredFieldValidator" ControlToValidate="body"
                        Text="*" ErrorMessage="'Body' is required." runat="server" />
                    <asp:HiddenField ID="createDate" Value='<%# Eval("BindCreateDate") %>' runat="server" />
                    <!--<asp:Button ID="submit" CommandName="Insert" Text="Save" runat="server" />-->
                    <asp:Button ID="insert" Text="Save" OnClick="save_Click" runat="server" />
                </LoggedInTemplate>
                <AnonymousTemplate>
                    Please login to create a new blog entry
                </AnonymousTemplate>
            </asp:LoginView>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:LoginView ID="loginView" runat="server">
                <LoggedInTemplate>
                    <h1>
                        Edit Blog Entry</h1>
                    <asp:Label ID="idLabel" Text="Id" runat="server" />
                    <asp:Label ID="id" Text='<%# Eval("Id") %>' runat="server" /><br />
                    <asp:Label ID="subjectLabel" Text='Subject' runat="server" />
                    <asp:TextBox ID="subject" Text='<%# Eval("Subject") %>' Width="300px" runat="server" /><br />
                    <asp:RequiredFieldValidator ID="subject_RequiredFieldValidator" ControlToValidate="subject"
                        Text="*" ErrorMessage="'Subject' is required." SetFocusOnError="True" runat="server" />
                    <ftb:FreeTextBox ID="body" Text='<%# Eval("Body") %>' ImageGalleryPath="~/Blog/Images"
                        ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,Strikethrough,Superscript,Subscript,RemoveFormat|Cut,Copy,Paste,Delete;Undo,Redo,Print,Save|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertImageFromGallery,NetSpell"
                        Width="100%" runat="server" />
                    <br />
                    <asp:RequiredFieldValidator ID="body_RequiredFieldValidator" ControlToValidate="body"
                        Text="*" ErrorMessage="'Body' is required." SetFocusOnError="True" runat="server" />
                    <asp:Label ID="pointsLabel" Text='Points' runat="server" />
                    <asp:TextBox ID="points" Text='<%# Eval("Points") %>' runat="server" /><br />
                    <asp:RequiredFieldValidator ID="points_RequiredFieldValidator" ControlToValidate="points"
                        Text="*" ErrorMessage="'Points' is required." SetFocusOnError="True" runat="server" />
                    <asp:Label ID="votesLabel" Text='Votes' runat="server" />
                    <asp:TextBox ID="votes" Text='<%# Eval("Votes") %>' runat="server" /><br />
                    <asp:RequiredFieldValidator ID="votes_RequiredFieldValidator" ControlToValidate="votes"
                        Text="*" ErrorMessage="'Votes' is required." SetFocusOnError="True" runat="server" />
                    <asp:Label ID="createDateLabel" Text='CreateDate' runat="server" />
                    <asp:HiddenField ID="createDate" Value='<%# Eval("BindCreateDate") %>' runat="server" />
                    <!--<asp:Button ID="submit" CommandName="Update" Text="Save" runat="server" />-->
                    <asp:Button ID="update" Text="Save" OnClick="save_Click" runat="server" />
                </LoggedInTemplate>
                <AnonymousTemplate>
                    Please login to create a new blog entry
                </AnonymousTemplate>
            </asp:LoginView>
        </EditItemTemplate>
    </asp:FormView>
    <asp:ObjectDataSource ID="blogs" SelectMethod="GetLatest" UpdateMethod="Save" InsertMethod="Save"
        DeleteMethod="Delete" DataObjectTypeName="Blog.Net.Business.BusinessObjects.BlogEntryBO"
        TypeName="Blog.Net.DataAccess.DataControls.BlogEntryDataControl" runat="server">
        <SelectParameters>
            <asp:Parameter Name="RecordCount" DefaultValue="-1" />
            <asp:QueryStringParameter Name="EntryId" QueryStringField="EntryId" DefaultValue="-1" />
            <asp:QueryStringParameter Name="MonthYear" QueryStringField="Filter" DefaultValue=""
                ConvertEmptyStringToNull="true" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
